package wc.Dao.bean;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * @ClassName:PageBean
 * @Author: 鹿建文
 * @Date: 2022/4/10  - 8:44
 * @Describe:
 */
@Getter
@Setter
@NoArgsConstructor
public class PageBean<T> {
    /**
     * 页码数
     */
    private Integer pageSize ;
    /**
     * 当前页码
     */
    private Integer pageNumber;
    /**
     * 一共有多少条记录
     */
    private Integer total;
    /**
     * 一共多少页
     */
    private Integer pages;
    /**
     * 每一页显示的数据
     */
    private List<T> records;

    public PageBean(Integer pageSize, Integer pageNumber, Integer total, List<T> records) {
        this.pageSize = pageSize;
        this.pageNumber = pageNumber;
        this.total = total;
        this.pages = this.total % this.pageSize == 0 ? this.total / this.pageSize : this.total / this.pageSize + 1;
        this.records = records;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

}
